/**
 * @addtogroup FXGE
 * @{
 */

/**
 * @file
 * @brief Foxit 2-D Graphic Engine (Special 565 Device Adapter).
 */
//<<<+++OPENSOURCE_MUST_BEGIN
#ifndef _FX_GE565_H_
#define _FX_GE565_H_
//<<<+++OPENSOURCE_MUST_END

#include "fx_dib565.h"
#include "fx_ge.h"

#define FXRC_RGB565_OUTPUT			0x400

/**
 * @brief Our own FXGE565 rendering device, using the internal FXGE565 device driver.
 * Supporting output to only following format:
 * # RGB565, normal RGB output.
 */
class CFX_GEDevice565 : public CFX_RenderDevice
{
public:
	/** Default constructor. */
	CFX_GEDevice565();

	/** The destructor. */
	~CFX_GEDevice565();

	/**
	 * Attach to an existing bitmap.
	 *
	 * @param[in] pBitmap		The bitmap to be attached.
	 * @param[in] dither_bits	The optional dithering bits. 0 for no dithering
	 */
	FX_BOOL			Attach(CFX_DIBitmap565* pBitmap565, int dither_bits = 0, FX_BOOL bRgbByteOrder = FALSE, CFX_DIBitmap* pOriDevice = NULL, FX_BOOL bGroupKnockout = FALSE);

	/**
	 * Create a new bitmap and attach to this device. 
	 * The bitmap will be destroyed when the device destructs.
	 *
	 * @param[in] width			The bitmap width.
	 * @param[in] height		The bitmap height.
	 * @param[in] format		The bitmap format. defined in fx_dib565.h
	 * @param[in] dither_bits	Number of bits per pixel for destination dithering. 
								For example, for a 4-gray scale EPD destination display, this should be 2.
								0 for no dithering used.
	 * @return FALSE if creation failed (OOM), or TRUE if success.
	 */
	FX_BOOL			Create(int width, int height, int dither_bits = 0);

	/** Get the bitmap of the device. */
	CFX_DIBitmap565*	GetBitmap565() const { return m_pBitmap565; }
	void				SetBitmap565(CFX_DIBitmap565* pBitmap565) { m_pBitmap565 = pBitmap565; }

protected:
	/** Whether the device manager the bitmap memory. */
	FX_BOOL			m_bOwnedBitmap;
	CFX_DIBitmap565* m_pBitmap565;
};
//<<<+++OPENSOURCE_MUST_BEGIN
#endif // _FX_GE565_H_
//<<<+++OPENSOURCE_MUST_END
/** @} */

